<?php

namespace App\Http\Controllers\Base;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\Input;
use Illuminate\Support\Facades\Session;
use Mews\Purifier\Facades\Purifier;

class Base extends Controller
{
    public $userTable, $recordTable;

    function __construct()
    {
        $this->userTable = Config::get('database.dbNames')['user'];
        $this->recordTable = Config::get('database.dbNames')['record'];
    }

    /**
     *  富文本过滤
     * @param $content
     * @return string
     */
    public function htmlPurifier($content){
        $input = strip_tags(Purifier::clean(Input::get($content)));
        return $input;
    }

    /**
     * 返回json数据
     * @param $status
     * @param $content
     * @param $data
     * @return string
     */
    public function returnJson($status, $content, $data){
        $returnData = array(
            'status' => $status,
            'content' => $content,
            'data' => $data
        );
        return json_encode($returnData);
    }

    /**
     *  判断登录状态
     * @return bool
     */
    public function checkLoginStatus(){
        $userInfo = Session::get('userInfo');
        $status = false;
        if ($userInfo['uid'] != ''){
            $status = true;
        }
        return $status;
    }
}
